package dao;

import pojo.Category;
import utils.DH;

import java.util.List;

/**
 * 商品分类dao
 * @author zjj
 */
public class CategoryDao {
    /**
     * 查询商品分类信息
     * @return
     */
    public List<Category> queryAllCategory() {
        String sql = "select * from t_category";
        List str = DH.getall(sql, new Category(), null);
        return str;
    }

    /**
     * 根据id查询信息
     * @param id
     * @return
     */
    public Category queryCategoryById(String id) {
        String sql = "select * from t_category where id=?";
        String[] args = {id};
        List str = DH.getall(sql, new Category(), args);
        if(str!=null && str.size()>0){
            Category cate = (Category) str.get(0);
            return cate;
        }
        return null;
    }
}
